<template>
<div id="dz_index" class="page in" data-title="">
    <div class="container">
		
        <div class="index-header"></div>
		
        <div class="index-bottom-wrap pa">
            
            <div class="index-title">机床配置与报价系统</div>

            <div class="login-wrap">
                <div class="icon user"><input type="text" placeholder="工号" v-model="frm.username"></div>
                <div class="icon pwd pr">
                    <input v-show="itype=='password'" type="password"  placeholder="密码" v-model="frm.password" />
                    <input v-show="itype=='text'" type="text"   placeholder="密码" v-model="frm.password" />
                    <span class="icon see pa" @click="seepasswd"></span>
                  
                </div>
            </div>
    
            <a href="javascript:void(0)" class="btn index-btn" @click="nflogin">登录</a>
 
            <!-- <navigator url="/pages/configinfo/custom" open-type="navigate">            
              <span>custom</span>
            </navigator>  -->

            <span class="index-bq pa">Copyright © 大族激光智能装备集团有限公司</span>
        </div>

    </div>
</div>
</template>

<script>
var mySelf;  
export default {
    data() {
      return {
        frm:{
            username:'DZ004',
            password:'123456'
        },
        itype :'password',

      }
    },
    methods: {
      seepasswd:function() {
 
        if (this.itype == 'password') {
            this.itype = 'text';
             
        } else {
            this.itype = 'password';
        }
      },
      nflogin:function() {
    
          if (!this.frm.username) {
                return this.$options.methods.showToast('请输入用户名');
            }
            if (!this.frm.password) {
                return this.$options.methods.showToast('请输入确认密码');
            }

            if (this.frm.password.length<6 ) { 
                return this.$options.methods.showToast('密码长度必须大等于6位');
            }
 
            this.$myUtils.myRequest({
                url: '/user/login',
                method:'post',
                data:this.frm
              }).then(res => {	
                console.log(res.data.data);		
                if (res.data.status!=200) {


                     return uni.showToast({
                        title: res.data.msg||'登录失败',
                        icon:'none',
                        duration:800
                      });
                }
                mySelf.$myUtils.saveStorage('userinfo', JSON.stringify(res.data.data));
                mySelf.$myUtils.saveStorage('userId', res.data.data.user_id);

                mySelf.$myUtils.saveStorage('token', res.data.token);
                mySelf.$myUtils.successGotoUrl('/pages/index/index');
                mySelf.imagecreate(res.data.data.user_id);

            })	
 
      },
       showToast(_title) {
          return uni.showToast({
                  title: _title,
                  icon:'none',
                  duration:500
                });
         
      },imagecreate(_user_id) {
          this.$myUtils.myRequest({
                url: '/diybase/imagecreate',
                method:'post',
                data:{'user_id':_user_id}
          }).then(res => {

          })	

      }
            
    },
    mounted() {
      mySelf = this;
      
    },
}
</script>